import {getCart,updateCart,getChecked,delGoods} from '../../api';

export function cartAction(){
    return async(dispatch:Function)=>{
        const result = await getCart();
        dispatch({
            type:'INIT_CART',
            payload:result.data
        })
    }
}
export function updateCartAction(goodsId:string,id:string,number:string,productId:string){
    return async(dispatch:Function)=>{
        const result = await updateCart(goodsId,id,number,productId);
        dispatch({
            type:'UPDATE_CART',
            payload:result.data
        })
    }
}
export function checkedCartAction(isChecked:number,productIds:string){
    return async(dispatch:Function)=>{
        const result = await getChecked(isChecked,productIds);
        dispatch({
            type:'CHECKED_CART',
            payload:result.data
        })
    }
}
export function delGoodstAction(productIds:string){
    return async(dispatch:Function)=>{
        const result = await delGoods(productIds);
        dispatch({
            type:'DEL_GOODS',
            payload:result.data
        })
    }
}
